<div class="page-header">
    <h1>Guestbook</h1>
</div>

<?php echo $this->action('block', 'auth')?>

<h2>Add message</h2>

<?php echo $this->messageForm?>

<h2>Messages</h2>

<?php if (count($this->paginator)):?>
<?php echo $this->paginationControl($this->paginator, 'Elastic', 'paginator.phtml')?>
<?php foreach ($this->paginator as $message):?>
<div class="row">
    <div class="span5">
    <?php $date = new Zend_Date($message->created_at);?>
    <?php echo $date?></div>
    <div class="span5">
    <?php echo $this->escape($message->username)?>
    </div>
    <div class="span3">
    <?php if ($this->isAllowed($message, 'edit')):?>
    <a href="<?php echo $this->url(array(
        'action' => 'edit',
        'id' => $message->id
    ), 'messages');?>">[edit]</a>
    <?php endif;?>
    </div>
    <div class="span3">
    <?php if ($this->isAllowed($message, 'delete')):?>
    <a href="<?php echo $this->url(array(
        'action' => 'delete',
        'id' => $message->id
    ), 'messages');?>">[delete]</a>
    <?php endif;?>
    </div>
</div>
<div class="row">
    <div class="span16">
    <?php echo $this->escape($message->text)?>
    </div>
</div>
<?php endforeach;?>
<?php echo $this->paginationControl($this->paginator, 'Elastic', 'paginator.phtml')?>
<?php else:?>
<p>No messages found</p>
<?php endif;?>